package com.robot.mq.listener;

import com.alibaba.fastjson.JSON;
import com.robot.mq.handler.WeChatNotifyHandler;
import entity.weixin.WeChatNotify;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @author wuyunbin
 */
@Component
@RabbitListener(queues = "notify")
public class WeChatNotifyListener {
    @Value("${spring.profiles.active}")
    private String env;
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    String prod = "prod";

    @RabbitHandler
    public void execute(String notify) {
        if (prod.equals(env)) {
            //开始处理业务
            WeChatNotifyHandler handler = new WeChatNotifyHandler();
            handler.sendMessageToUser(notify);
        }
    }
}
